package realQuestion.jingwei;

public class Main1 {


    public int candy (int[] arr) {
        // write code here
        int temp1;
        int temp2;
        if (arr.length==0){
            return 0;
        }
      if (arr.length==1){
          return 1;
      }
   if (arr[1]>arr[0]){
       temp1=1;
       temp2=2;
   }else if (arr[1]==arr[0]){
       temp1=1;
       temp2=1;
   }else {
       temp1=2;
       temp2=1;
   }
   int sum=temp1+temp2;
        for (int i = 2; i < arr.length; i++) {
            if (arr[i]>arr[i-1]){
                temp2++;
            }else {
                temp2=1;
            }
            sum+=temp2;
        }

        return  sum;
    }

}
